package vistas.abstractModels;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import entidades.Material;

public class MaterialTableModel extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String[] columnNames = { "Identificador", "Tipo", "Descripción" };
	private Object[][] data;
	private int numberOfRows;

	public MaterialTableModel(List<Material> rows) {
		data = new Object[rows.size()][columnNames.length];
		numberOfRows = rows.size();

		for (int i = 0; i < rows.size(); i++) {
			data[i][0] = String.valueOf(rows.get(i).getId());
			data[i][1] = rows.get(i).getTipo();
			data[i][2] = rows.get(i).getDescripcion();

		}
	}

	@Override
	public int getRowCount() {
		return numberOfRows;
	}

	@Override
	public int getColumnCount() {
		return columnNames.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return data[rowIndex][columnIndex];
	}

	public String getColumnName(int index) {
		return columnNames[index];

	}

}
